package com.hdu.xxlJobLocalCacheFix.aspect;


import com.xxl.job.core.context.XxlJobHelper;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class XxlJobAspect {

    @Pointcut("@annotation(com.xxl.job.core.handler.annotation.XxlJob)")
    public void xxlJobPointCut() {
    }

    @Around("xxlJobPointCut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        try {
            Object[] args = point.getArgs();
            if (args != null && args.length > 0) {
                args[0] = XxlJobHelper.getJobParam();
            }
            return point.proceed(args);
        } catch (Exception e) {
            return point.proceed();
        }
    }
}
